﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;

namespace CTEA_INDIA
{
    public partial class Enquiry : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            BAL.conn.connectionString = ConfigurationManager.ConnectionStrings["CTEA"].ConnectionString;
            //if (Session["UserId"] == null || Session["UserId"].ToString() == "")
            //{
            //    Session.Abandon();
            //    Session.RemoveAll();
            //    Response.Redirect("Default.aspx");
            //}
            if (!IsPostBack)
            {
                // ddlPreproduction.Attributes.Add("onChange", "return OnSelectedIndexChange();");

                BAL.Customers.PopulateLocation(ref ddlLocation);
              
               

            }
        }

        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                string Name = txtName.Text;
                string Address = txtAddress .Text;
                string Contactno = txtContactNo.Text;
                string InterestedField = ddlInterestedField.SelectedValue;
                string Interestedfield2 = ddlPreproduction.SelectedValue;
                string InterestedField3 = ddlEducation.SelectedValue;
                string IField = InterestedField + Interestedfield2 + InterestedField3;
                string loc = ddlLocation.SelectedValue;


                string EmailId = txtEmailId.Text;
                BAL.Customers.InsertEnquiry(Name, Address, Contactno, IField,loc);
                clear();

            }
        }

      

        protected void ddlPreproduction_SelectedIndexChanged(object sender, EventArgs e)
        {
          
                string Value = ddlPreproduction.SelectedItem.Value;
                if (Value == "Education")
                {
                    ddlEducation.Visible = true;
                }
                else
                {
                    ddlEducation.Visible = false;
                }
               
        }


        public void clear()
        {
            txtName.Text = "";
            txtAddress.Text = "";
            txtContactNo.Text = "";
            ddlInterestedField.Visible = true;
            ddlPreproduction.Visible = false;
            ddlEducation.Visible = false;

        }

        protected void ddlInterestedField_SelectedIndexChanged(object sender, EventArgs e)
        {


            string Value = ddlInterestedField.SelectedItem.Value;
            if (Value == "PreProduction")
            {

                ddlPreproduction.Visible = true;
            }
            else
            {
                ddlPreproduction.Visible = false;
                ddlEducation.Visible = false;
            }
        }
    }
}




  

